import hashlib


class Hash:
    def __init__(self):
        self.keys = []
        self.node_list = []
        self.nodes = {}
        self.request_number = 0
        self.hit_number = 0

    def _hash(self, key):
        """
        根据key值计算hash值
        :param key:
        :return:
        """
        return int(hashlib.md5(key.encode('utf-8')).hexdigest(), 16)

    def set(self, key, value):
        pass

    def get(self, key):
        self.request_number += 1
        pass

    def add_node(self, node, index):
        self.node_list.insert(index, node)
        pass

    def remove_node(self, node):
        self.node_list.remove(node)
        return node
        pass

    def hit_accuracy(self):
        return self.hit_number / self.request_number
